package com.cwl;

import com.cwl.utils.EasySearchOption;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * spring 容器启动之后事件
 * @author cwledit
 */
@Component
public class OneApplicationStartup implements ApplicationListener<ContextRefreshedEvent> {


    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {

        if (contextRefreshedEvent != null && contextRefreshedEvent.getApplicationContext().getParent() == null) {
            try {
                /* 初始化 **/
                initEasySearch();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }

    private void initEasySearch(){
        EasySearchOption.initEasySearch();
    }

}
